/**
 * @param {string} s
 * @return {number}
 */
 var maxProduct = function(s) {
  const n = s.length
  const check = (str) => {
    if(str.length === 0){
      return false
    }
    return str === str.split('').reverse().join('')
  }
  const template = [], pathList = []
  const dfs = (str, idx, path) =>{
    if(check(str)){
      template.push(str)
      pathList.push(path)
    }
    if(idx >= n){
      return
    }
    for(let i = idx; i<n; i++){
      dfs(str+s[i], i+1, [...path, i])
    }
  } 
  dfs('', 0, [])
  const isNoInter = (x, y) => {
    const sset = new Set(x)
    for(const ch of y){
      if(sset.has(ch)){
        return false
      }
    }
    return true
  }
  let ans = 0
  const m = pathList.length
  for(let i = 0; i<m; i++){
    for(let j = i+1; j<m; j++){
      if(isNoInter(pathList[i], pathList[j])){
        ans = Math.max(ans, pathList[i].length * pathList[j].length)
      }
      
    }
  }
  return ans
};